import { FC, ReactNode, CSSProperties } from 'react'
import { FormProps, FormItemProps, Form as AntdForm } from 'antd'

export interface Props {
  formProps?: FormProps
  formItemConf?: { node: ReactNode; conf: FormItemProps; style?: CSSProperties }[]
}

const Form: FC<Props> = ({ formProps, formItemConf }) => {
  return (
    <AntdForm {...formProps}>
      {formItemConf ? (
        formItemConf?.map((formItem, formIndex) => {
          return (
            <AntdForm.Item key={formIndex} {...formItem.conf} style={formItem.style}>
              {formItem.node}
            </AntdForm.Item>
          )
        })
      ) : (
        <></>
      )}
    </AntdForm>
  )
}
export default Form
